﻿<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
</h:head>

<h:body>
	<p:scrollPanel mode="native" style="width:100%;height:100%;">
		<h:form id="form">
			<p:growl id="growl" life="3000" />
			<p:dataTable id="tblFaces" var="face"
				value="#{facequadraBean.facesquadra}" paginator="true" rows="10"
				style="margin-bottom:20px" rowsPerPageTemplate="5,10,15"
				emptyMessage="Nenhuma face de quadra cadastrada." editable="true">

				<p:ajax event="rowEdit" listener="#{facequadraBean.onRowEdit}"
					update=":form:growl" />
				<p:ajax event="rowEditCancel"
					listener="#{facequadraBean.onRowCancel}" update=":form:growl" />

				<f:facet name="header">
	       		 	Lista de faces de quadra
	    		</f:facet>

				<p:column headerText="Número" filterBy="#{face.numeroFacequadra}"
					filterMatchMode="contains">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{face.numeroFacequadra}" />
						</f:facet>
						<f:facet name="input">
							<p:inputMask mask="?9999" required="true"
								requiredMessage="Número da face de quadra não informado!"
								value="#{face.numeroFacequadra}" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<!-- 
				<p:column headerText="Setor fiscal">
				</p:column>

				<p:column headerText="Quadra">
				</p:column>

				<p:column headerText="Logradouro">
				</p:column>
				 -->

				<p:column headerText="Prancha" filterBy="#{face.pranchaFacequadra}"
					filterMatchMode="contains">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{face.pranchaFacequadra}" />
						</f:facet>
						<f:facet name="input">
							<p:inputMask mask="999999" required="true"
								requiredMessage="Código da prancha não informado!"
								value="#{face.pranchaFacequadra}" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="CEP" filterBy="#{face.cepFacequadra}"
					filterMatchMode="contains">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{face.cepFacequadra}" />
						</f:facet>
						<f:facet name="input">
							<p:inputMask mask="99999-999" maxlength="9"
								value="#{face.cepFacequadra}" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="Situação"
					filterBy="#{face.situacaoFacequadra}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{face.situacaoFacequadra}" />
						</f:facet>
						<f:facet name="input">
							<p:selectOneMenu value="#{face.situacaoFacequadra}"
								style="width:100%">
								<f:selectItem itemLabel="Normal" itemValue="N" />
			﻿  ﻿  ﻿              				<f:selectItem itemLabel="Excluido"
									itemValue="E" />
							</p:selectOneMenu>
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="Última atualização"
					filterBy="#{face.dataAtuFacequadra}">
					<h:outputText value="#{face.dataAtuFacequadra}" />
				</p:column>

				<p:column width="3%">
					<p:rowEditor />
				</p:column>

				<p:column width="3%">
					<p:commandLink action="#{facequadraBean.excluir}"
						onclick="if (!confirm('Confirmar a exclusão da face de quadra  #{face.numeroFacequadra}?')) return false;"
						update=":form:tblFaces">
						<h:outputText styleClass="ui-icon ui-icon-trash"
							style="margin:0 auto;" />
						<f:setPropertyActionListener value="#{face}"
							target="#{facequadraBean.facequadra}" />
					</p:commandLink>
				</p:column>

				<f:facet name="footer">
	        				Número de faces de quadra: #{facequadraBean.numeroFacesquadraCadastradas()}.
	    				</f:facet>
			</p:dataTable>

			<h3>Exportar</h3>
			<h:commandLink>
				<p:graphicImage url="imagens/excel.png" width="24" />
				<p:dataExporter type="xls" target="tblFaces" fileName="faces"
					pageOnly="true" />
			</h:commandLink>

			<h:commandLink>
				<p:graphicImage url="imagens/pdf.png" width="24" />
				<p:dataExporter type="pdf" target="tblFaces" fileName="faces"
					pageOnly="true" />
			</h:commandLink>
		</h:form>
	</p:scrollPanel>
</h:body>
</html>